CC = ${COMPILER_PREFIX}gcc
CFLAGS = -c -Wall  -I.
LDFLAGS = -lpthread

SOURCES = merge.c sparse_matrix.c huffman.c stack.c queue.c bigdata.c
OBJECTS = $(SOURCES:.c=.o)
MERGE = merge
MATRIX = cmatrix
HUFFMAN = chuffman
STACK = stack
QUEUE = queue
GRAPH = graph
CALC_PI = pi

all: $(SOURCES) $(MERGE) $(MATRIX) $(HUFFMAN) $(STACK) $(QUEUE) $(GRAPH) $(CALC_PI)

$(MERGE): merge.o
	$(CC) merge.o -o $@ $(LDFLAGS)

$(MATRIX): sparse_matrix.o
	$(CC) sparse_matrix.o -o $@ $(LDFLAGS)

$(HUFFMAN): huffman.o
	$(CC) huffman.o -o $@ $(LDFLAGS)

$(STACK): stack.o
	$(CC) stack.o -o $@ $(LDFLAGS)

$(QUEUE): queue.o
	$(CC) queue.o -o $@ $(LDFLAGS)

$(GRAPH): graph.o
	$(CC) graph.o -o $@ $(LDFLAGS)

$(CALC_PI): bigdata.o
	$(CC) bigdata.o -o $@ $(LDFLAGS)


.c.o:
	$(CC) $(CFLAGS) $< -o $@

clean:
	rm -f *.o $(MERGE) $(MATRIX) $(HUFFMAN) $(STACK) $(QUEUE) $(GRAPH) $(CALC_PI)
